package jmine.tec.hydra.actions.validator;

import java.util.List;

import jmine.tec.hydra.actions.domain.MockAuthorizableEntity;
import bancosys.tec.persist.Persistable;
import bancosys.tec.persist.validator.AbstractBeanValidator;
import bancosys.tec.persist.validator.ValidationError;

@SuppressWarnings("deprecation")
public class MockAuthorizableEntityValidator extends AbstractBeanValidator {

    @Override
    public List<ValidationError> customInsertValidation(Persistable bean) {
        MockAuthorizableEntity entity = (MockAuthorizableEntity) bean;
        if (entity.getValidationException() != null) {
            throw entity.getValidationException();
        }
        List<ValidationError> errors = null;
        if (entity.getValidationError() != null) {
            errors = this.addError(errors, entity.getValidationError());
        }
        return errors;
    }

    @Override
    public List<ValidationError> customRemoveValidation(Persistable bean) {
        MockAuthorizableEntity entity = (MockAuthorizableEntity) bean;
        if (entity.getValidationException() != null) {
            throw entity.getValidationException();
        }
        List<ValidationError> errors = null;
        if (entity.getValidationError() != null) {
            errors = this.addError(errors, entity.getValidationError());
        }
        return errors;
    }

    @Override
    public List<ValidationError> customUpdateValidation(Persistable bean) {
        MockAuthorizableEntity entity = (MockAuthorizableEntity) bean;
        if (entity.getValidationException() != null) {
            throw entity.getValidationException();
        }
        List<ValidationError> errors = null;
        if (entity.getValidationError() != null) {
            errors = this.addError(errors, entity.getValidationError());
        }
        return errors;
    }

}
